package com.night.administration.controller;

import com.night.administration.service.StructureService;
import com.night.common.entity.ResultVo;
import com.night.common.entity.administration.Structure;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: TeacherController
 * @Description: //TODO
 * @author: LZJ
 * @date: 2022/10/23-14:15
 * @version: v1.0
 */
@RestController
@RequestMapping("/api/v1/structure")
public class StructureController {
    @Resource
    private StructureService structureService;

//    @PostMapping("/list")
//
//    public ResultVo<Course> getAllByCondition(@RequestBody Course course) {
//        return new ResultVo(courseService.getByCondition(course));
//    }

    @PostMapping("/add")
    public ResultVo<String> add(@RequestBody Structure structure) {
        structureService.insert(structure);
        return ResultVo.SUCCESS;
    }

    @PostMapping("/getMajor")
    public ResultVo<Structure> update(@RequestBody Structure structure) {
       return new ResultVo(structureService.getMajorByCollege(structure.getCollege()));
    }

    @PostMapping("/getCollege")
    public ResultVo<List<Structure>> getCollege() {
        return new ResultVo<>(structureService.getCollege());
    }
}
